home *** CD-ROM | disk | FTP | other *** search
/ PC Media 2 / PC MEDIA CD02.iso / share / prog / realasm1 / ftfact.asm < prev    next >
Encoding:
Assembly Source File  |  1993-07-18  |  1.1 KB  |  33 lines

  1. .286
  2. ;================================================
  3. ; invoke ftfact, real, factorial
  4. ;
  5. ; Returns real = !factorial
  6. ;------------------------------------------------
  7. cseg          segment word public 'code'
  8.               assume  cs:cseg,ss:cseg
  9.               assume  ds:cseg,es:cseg
  10.  
  11.               include math.inc
  12.  
  13. ftfact        proc    near uses cx si di, real:NPR10, factorial:WORD
  14.               local   t:REAL10
  15.  
  16.               mov     si, real                  ;
  17.               invoke  load1, si                 ; real = 1.0
  18.               lea     di, t                     ; address t
  19.               mov     cx, factorial             ;
  20.  
  21.               .WHILE (1)                        ;
  22.                  invoke  itoft, di, cx          ; convert cx to a REAL10 (t)
  23.                  invoke  ftmul, si, di          ; real *= t
  24.                  dec     cx                     ; next factorial value
  25.                  .BREAK .IF (cx == 1)           ; don't mult by 1
  26.               .ENDW
  27.  
  28.               ret
  29. ftfact        endp
  30.  
  31. cseg          ends
  32.               end
  33.